var onPause = function() {
  console.log('Pause');
};

var onResume = function() {
  console.log('Resume');
};

var onBatteryStatus = function(e) {
  console.log("Level: " + e.level);
};

var onBatteryLow = function(e) {
  console.log("Level: " + e.level);
};

var onBatteryCritical = function(e) {
  console.log("Level: " + e.level);
};

var onDeviceReady = function() {
  document.addEventListener('pause', onPause, false);
  document.addEventListener('resume', onResume, false);

  // http://docs.phonegap.com/en/1.5.0/phonegap_events_events.md.html#batterystatus
  window.addEventListener('batterystatus', onBatteryStatus, false);
  window.addEventListener('batterylow', onBatteryLow, false);
  window.addEventListener('batterycritical', onBatteryCritical, false);
  
  
};

$(function() {
  console.log('Init');
  document.addEventListener('deviceready', onDeviceReady, false);
  
  $('#clickgeo').click(function(){
	//navigator.geolocation.getCurrentPosition(onSuccess, onError);  
	navigator.camera.getPicture(onSuccess, onFail, { 
			quality: 50, 
			destinationType: Camera.DestinationType.FILE_URI,
			targetWidth:200,
			targetHeight:300
		  }
	); 
	});
});

function onSuccess(imageURI) {
    $('#myimage').attr('src',imageURI);
}

function onFail(message) {
    alert('Failed because: ' + message);
}

		/*// onSuccess Callback
		//   This method accepts a `Position` object, which contains
		//   the current GPS coordinates
		//
		var onSuccess = function(position) {
		    alert('Latitude: '          + position.coords.latitude          + '\n' +
		          'Longitude: '         + position.coords.longitude         + '\n' +
		          'Altitude: '          + position.coords.altitude          + '\n' +
		          'Accuracy: '          + position.coords.accuracy          + '\n' +
		          'Altitude Accuracy: ' + position.coords.altitudeAccuracy  + '\n' +
		          'Heading: '           + position.coords.heading           + '\n' +
		          'Speed: '             + position.coords.speed             + '\n' +
		          'Timestamp: '         + new Date(position.timestamp)      + '\n');
		};
		
		// onError Callback receives a PositionError object
		//
		function onError(error) {
		    alert('code: '    + error.code    + '\n' +
		          'message: ' + error.message + '\n');
		}*/
